#define _CRT_SECURE_NO_WARNINGS 1
//#include <iostream>
//using namespace std;
//const int N = 1e5 + 10;
//int q[N], f[N];
//int n;
//int main()
//{
//    scanf("%d", &n);
//    for (int i = 0; i < n; i++)
//        scanf("%d", &q[i]);
//    int res = 1;
//    int j = 1;
//    for (int i = 0; i < n; i)
//    {
//        j = i;
//        f[q[i]] ++;
//        while (f[q[j]] <= 1) f[q[++j]] ++;
//        res = max(j - i + 1, res);
//        while (i <= j) f[q[i++]] --;
//        i--;
//    }
//    printf("%d", res);
//    return 0;
//}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
vector<PII> add, query;
vector<int> alls;
int q[N], s[N];
int n, m;
int find(int x)
{
    int l = 0, r = alls.size() - 1;
    while (l < r)
    {
        int mid = l + r >> 1;
        if (alls[mid] >= x) r = mid;
        else l = mid;
    }
    return l;
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        int x, c;
        scanf("%d%d", &x, &c);
        add.push_back({ x, c });
        alls.push_back(x);
    }
    for (int i = 0; i < m; i++)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        query.push_back({ l, r });
        alls.push_back(l);
        alls.push_back(r);
    }
    sort(alls.begin(), alls.end());
    alls.erase(unique(alls.begin(), alls.end()), alls.end());
    for (auto p : add)
    {
        int f = find(p.first);
        q[f] += p.second;
    }
    s[0] = q[0];
    for (int i = 1; i < alls.size(); i++)
        s[i] += s[i - 1] + q[i];
    for (auto p : query)
    {
        int l = find(p.first), r = find(p.second);
        printf("%d\n", s[r] - s[l - 1]);
    }
    return 0;
}